package config

import (
	"io/ioutil"

	"gopkg.in/yaml.v2"
)

type DBConfig struct {
	Host     string `yaml:"host"`
	User     string `yaml:"user"`
	Port     int    `yaml:"port"`
	Password string `yaml:"password"`
	Database string `yaml:"database_name"`
}

type Config struct {
	SiteName string   `yaml:"site_name"`
	Database DBConfig `yaml:"database"`
}

var Conf Config

func init() {
	GetConfig()
}

func GetConfig() Config {
	data, _ := ioutil.ReadFile("./config.yaml")
	config := Config{}
	yaml.Unmarshal(data, &config)
	Conf = config
	return config
}
